<?php

/**
 * This is the model class for table "city_recommend".
 *
 * The followings are the available columns in table 'city_recommend':
 * @property integer $id ID
 * @property string $type 类型
 * @property integer $city 城市
 * @property integer $sort 排序
 */
class CityRecommend extends ActiveRecord
{
	/**
	 * 景点门票
	 * Enter description here ...
	 * @var string
	 */
	const TYPE_INDEX_SCENIC = 'index_scenic';
	/**
	 * 机票
	 * Enter description here ...
	 * @var string
	 */
	const TYPE_INDEX_TICKET = 'index_ticket';
	/**
	 * 酒店
	 * Enter description here ...
	 * @var string
	 */
	const TYPE_INDEX_HOTEL = 'index_hotel';
	/**
	 * 土特产
	 * Enter description here ...
	 * @var string
	 */
	const TYPE_NATIVE = 'native';
	/**
	 * 出境旅游
	 */
	const TYPE_TRAVEL_EXIT = 'exit_travel';
	/**
	 * 国内旅游
	 * Enter description here ...
	 * @var unknown_type
	 */
	const TYPE_TRAVEL_INTERNAL = 'internal_travel';
	/**
	 * Returns the static model of the specified AR class.
	 * @return CityRecommend the static model class
	 */
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}
	
	public function getMdcClass() {
		return 'application.models.metadata.CityRecommendMetadata';
	}
	
	public function getCityName() {
		return LyUtis::cityName($this->city);
	}
	
	static public function typeCity($type, $limit = 10) {
		$criteria = new CDbCriteria();
		$criteria->compare('type', $type);
		$criteria->limit = $limit;
		$criteria->order = 'sort desc';
		return self::model()->findAll($criteria);
	}
	
	static public function typeCityList($type, $limit = 0 ) {
		$data = self::typeCity($type,$limit);
		return CHtml::listData($data, 'city', 'cityName');
	}
}